package com.mindata.blockmanager.constant;

import java.util.HashMap;
import java.util.Map;

/**
 * 对表的权限
 *
 * @author wuweifeng wrote on 2018/4/10.
 */
public enum PermissionType {
    OWNER(new Byte("1"), "表的创建者"),
    ALL(new Byte("2"), "全部"),
    ADD(new Byte("3"), "新增"),
    UPDATE(new Byte("4"), "修改"),
    DELETE(new Byte("5"), "删除"),
    NONE(new Byte("6"), "不可见");

    private Byte key;
    private String value;

    PermissionType(Byte key, String value) {
        this.key = key;
        this.value = value;
    }

    public Byte getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }


    private static final Map<Byte, PermissionType> ENUMMAP = new HashMap<Byte, PermissionType>();

    static {
        for (PermissionType permissionType : PermissionType.values()) {
            ENUMMAP.put(permissionType.getKey(), permissionType);
        }
    }

    public static PermissionType fromValue(Byte key) {
        return ENUMMAP.get(key);
    }
}
